import { defineStore } from "pinia";
import { store } from "/@/store";

export const useProjectStore = defineStore({
  id: "pure-project",
  state: () => ({
    rightRefresh: "",
    leftRefresh: "",
    isHidden: true,
    projectTypeList: [],
    projectType: {}
  }),
  actions: {
    rightSetting() {
      this.rightRefresh = new Date().getTime();
    },

    leftSetting() {
      this.leftRefresh = new Date().getTime();
    },

    // 控制左侧树结构收缩
    isHiddenSetting() {
      this.isHidden = !this.isHidden;
    },

    // 项目类型列表
    setProjectTypeList(list) {
      this.projectTypeList = list || [];
      list.forEach(item => {
        this.projectType[item.dicCode] = item.dicValue;
      });
    }
  }
});

export function useProjectStoreHook() {
  return useProjectStore(store);
}
